/**
 * 
 */
package es.ats.codington.festival.junit;

import java.util.ArrayList;
import java.util.HashMap;



import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import junit.framework.TestCase;
import es.ats.codington.festival.domain.Stadium;
import es.ats.codington.festival.domain.Zoo;
import es.ats.codington.festival.domain.Place.Real;
import es.ats.codington.festival.domain.Place.Zone;
import es.ats.codington.festival.services.PlaceServiceImpl;

/**
 * The Class TNewPlace.
 *
 * @author JAVA101_01
 */
public class TNewPlace extends TestCase{

	/**
	 * Sets the up.
	 *
	 * @throws Exception the exception
	 */
	@Before
	public void setUp() throws Exception {
	}

	/**
	 * Tear down.
	 *
	 * @throws Exception the exception
	 */
	@After
	public void tearDown() throws Exception {
	}

	
	/**
	 * Test inserta place.
	 *
	 * @throws Exception the exception
	 */
	@Test
	public void testInsertaPlace() throws Exception{
	
/**
 *insert places
 *
   		Museum building = new Museum("merlin", "escultura", "Gughinheim", 264, "Museo de cera", Zone.south);
   	*	Stadium building = new Stadium("merlin", "escultura",false,  "Gughinheim", 264, "Museo de cera", Zone.south, Real.stadium);
   		PlaceServiceImpl placeS1 = new PlaceServiceImpl();
//*/

/**
	 * insert places
	 * 
	 */
   		Zoo place = new Zoo("Perico", 123, "Tomas", 4457, "Heurtel", Zone.south, Real.zoo);
   		PlaceServiceImpl placeS = new PlaceServiceImpl();
   		//*/
 
 		

   		
	  boolean aux = placeS.registerPlace(place);
	   
	  //boolean aux2 = placeS1.registerBuilding(building);
   	//	boolean aux = placeS1.deletePlace(building);
   		//Thread.sleep(10000);
	//	boolean aux2 = placeS.deletePlace(place);

   		
   		try {
			assertEquals(false, aux);
			//assertEquals(true, aux2);			
		
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
   		
	}	
	
	
	/*
	@Test
	public void testShowAllPlaces() {	
		PlaceServiceImpl placeS = new PlaceServiceImpl();
		boolean rs = placeS.ShowPlaceAll();
		
		ArrayList<Integer> places = new ArrayList<Integer>();
		ArrayList<String> names = new ArrayList<String>();

	//	places = placeS.obtainAllPlaces();
		
		HashMap<Integer, String> myPlaces = new HashMap<Integer, String>();
		myPlaces = placeS.obtainNameAndId();
		
		Iterator it = myPlaces.keySet().iterator();
		while (it.hasNext()) {
			
			Integer key = (Integer)it.next();
			
			places.add(key);
			names.add(myPlaces.get(key));
			//System.out.println("Clave: " + key + " -> Valor: " + myPlaces.get(key));
		}
	
		try{	
		assertEquals(true, rs);

		}
	catch (Exception ex){
		fail("exception trough");
	}												
													
}	*/
	
	
	/**
	 * Test show places id.
	 */
	@Test
	public void testShowPlacesId() {	
		PlaceServiceImpl placeS = new PlaceServiceImpl();
		boolean rs = placeS.ShowPlacesId(2);
		
		
		
try{	
		assertEquals(true, rs);

		}
	catch (Exception ex){
		fail("exception trough");
	}												
														

}	
	
	
	
		
	@Test
	public void testPlace() {	
			
		Stadium stadium2 = new Stadium("Estadio de Vallecas", "Athletics", true, "Teresa Rivero", 15000, "Sport", Zone.north, Real.stadium);
	try{	
		assertEquals("Estadio de Vallecas",stadium2.getStadiumName());
		assertEquals("Athletics",stadium2.getTypeSport());
		assertEquals(true,stadium2.isIndoor());
		assertEquals("Teresa Rivero",stadium2.getPlaceName());
		assertEquals(15000,stadium2.getCapacity());
		assertEquals("Sport",stadium2.getPlaceDescription());
		assertEquals(Zone.north, stadium2.getZone());
		}
	catch (Exception ex){
		fail("exception trough");
	}	
	}
	
	

}
